package com.productivity.model.common;

import java.io.Serializable;

public class Vertex3D extends Vector3D implements Serializable {
	public Vertex3D() {
		super();
	}
	public Vertex3D(float x, float y, float z) {
		super(x,y,z);
	}
	public Vertex3D(String[] elements) {
		setX(Float.parseFloat(elements[1]));
		setY(Float.parseFloat(elements[2]));
		setZ(Float.parseFloat(elements[3]));
	}
	public Vertex3D(Vertex3D start, Vertex3D end, float frac) {
		setX(start.getX() + ((end.getX()-start.getX())*frac));
		setY(start.getY() + ((end.getY()-start.getY())*frac));
	}
	public Vertex3D scale(float scale) {
		return new Vertex3D(getX()*scale,getY()*scale, getZ()*scale);
	}
	public Vertex3D addVector(Vector3D vec) {
		return new Vertex3D(vec.getX()+getX(), vec.getY()+getY(),vec.getZ()+getZ());
	}
	public static Vertex3D[] floatToVertex3DArray(float[] arr) {
		Vertex3D[] ret = new Vertex3D[arr.length/3];
		for(int i = 0; i < ret.length; i++)
			ret[i] = new Vertex3D(arr[i*3],arr[i*3+1],arr[i*3+2]);
		return ret;
	}
}
